<?php
// +----------------------------------------------------------------------
// | 跃飞 [ 将来的你一定会感激现在奋斗的自己 ]
// +----------------------------------------------------------------------
// | Author: 钟贵廷
// +----------------------------------------------------------------------
// | Author URI: https://git.oschina.net/yeafy
// +----------------------------------------------------------------------
// | weChat:gt845272922  qq:845272922
// +----------------------------------------------------------------------


namespace app\home\controller;
use app\yeafy\singleton\Pdo;
use app\yeafy\singleton\Student;
use think\Controller;

class Singleton extends Controller
{
    /**
     * @desc:单例实现pdo
     * @author 钟贵廷
     * @WeChat gt845272922
     * @qq 845272922
     */
    public function pdo()
    {
        $a = Pdo::getInstance();
        $b = Pdo::getInstance();
        p($a === $b);

    }

    public function student()
    {
        $st1 = Student::getInstance();
        $st1->setAge(23);
        echo "st1对象的年龄是{$st1->getAge()}<br/>";
        $st2 = Student::getInstance();
        $st2->setAge(30);
        echo "st2对象的年龄是{$st2->getAge()}<br/>";
        echo "st1对象的年龄是{$st1->getAge()}<br/>";

    }
}